<%--
  Created by IntelliJ IDEA.
  User: 吴慧跃
  Date: 2022/5/19
  Time: 23:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<html>
<head>
    <title>列表</title>
    <link href="/static/css/bootstrap.css" rel="stylesheet">
    <script type="text/javascript" src="/static/js/jquery-3.2.1.js"></script>
    <script src="/static/js/echarts.js"></script>
</head>
<body>
<div class="container">
    <form action="/user/list" method="post">
        出生日期：<input type="date" name="min" value="<fmt:formatDate value="${vo.min}" pattern="yyyy-MM-dd"/>"> -
        <input type="date" name="max" value="<fmt:formatDate value="${vo.max}" pattern="yyyy-MM-dd"/>">
        <input type="submit" value="查询">
    </form>
    <table class="table table-hover">
        <tr>
            <td>id</td>
            <td>姓名</td>
            <td>性别</td>
            <td>密码</td>
            <td>电话</td>
            <td>生日</td>
            <td>操作</td>
        </tr>
        <c:forEach items="${pg.list}" var="user">
            <tr>
                <td>${user.id}</td>
                <td>${user.username}</td>
                <td>${user.sex}</td>
                <td>${user.password}</td>
                <td>${user.telephone}</td>
                <td>
                    <fmt:formatDate value="${user.birthday}" pattern="yyyy-MM-dd"/>
                </td>
                <td>
                    <input type="button" value="修改" onclick="update(${user.id})">
                    <input type="button" value="删除" onclick="del(${user.id})">
                </td>
            </tr>
        </c:forEach>
    </table>
    <jsp:include page="/static/common/pages.jsp"/>
</div>
<script>
    function update(id) {
        location="/user/toUpdate?id="+id;
    }
    function del(id) {
        $.post("/user/del",{id:id},function (msg) {
            if (msg){
                alert("删除成功");
                location.reload();
            }else{
                alert("删除失败");
            }
        });
    }
</script>
</body>
</html>
